#include "mainwindow.h"
#include "QGraphicsDropShadowEffect"
#include "QtDebug"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    setupUi();
    btnConnect();

}

MainWindow::~MainWindow()
{
}

void MainWindow::setupUi()
{
    centralwidget = new QWidget(this);
    centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
    groupBox_last = new QGroupBox(centralwidget);
    groupBox_last->setObjectName(QString::fromUtf8("groupBox_last"));
    groupBox_last->setGeometry(QRect(1210, 620, 170, 153));
    QFont font;
    font.setPointSize(20);
    font.setBold(true);
    font.setWeight(75);
    groupBox_last->setFont(font);
    gridLayout_7 = new QGridLayout(groupBox_last);
    gridLayout_7->setObjectName(QString::fromUtf8("gridLayout_7"));
    pBtn_export = new QPushButton(groupBox_last);
    pBtn_export->setObjectName(QString::fromUtf8("pBtn_export"));
    pBtn_export->setMinimumSize(QSize(150, 50));
    pBtn_export->setMaximumSize(QSize(150, 50));

    gridLayout_7->addWidget(pBtn_export, 0, 0, 1, 1);

    pBtn_shutdown = new QPushButton(groupBox_last);
    pBtn_shutdown->setObjectName(QString::fromUtf8("pBtn_shutdown"));
    pBtn_shutdown->setMinimumSize(QSize(150, 50));
    pBtn_shutdown->setMaximumSize(QSize(150, 50));

    gridLayout_7->addWidget(pBtn_shutdown, 1, 0, 1, 1);

    pTextEdit_log = new QPlainTextEdit(centralwidget);
    pTextEdit_log->setObjectName(QString::fromUtf8("pTextEdit_log"));
    pTextEdit_log->setGeometry(QRect(33, 340, 1171, 441));
    widget = new QWidget(centralwidget);
    widget->setObjectName(QString::fromUtf8("widget"));
    widget->setGeometry(QRect(32, 21, 674, 42));
    gridLayout = new QGridLayout(widget);
    gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
    gridLayout->setContentsMargins(0, 0, 0, 0);
    label_preson = new QLabel(widget);
    label_preson->setObjectName(QString::fromUtf8("label_preson"));
    QFont font1;
    font1.setPointSize(16);
    font1.setBold(true);
    font1.setWeight(75);
    label_preson->setFont(font1);

    gridLayout->addWidget(label_preson, 0, 0, 1, 1);

    lineEdit_preson = new QLineEdit(widget);
    lineEdit_preson->setObjectName(QString::fromUtf8("lineEdit_preson"));
    lineEdit_preson->setMinimumSize(QSize(120, 40));
    lineEdit_preson->setMaximumSize(QSize(120, 40));
    QFont font2;
    font2.setPointSize(15);
    font2.setBold(false);
    font2.setWeight(50);
    lineEdit_preson->setFont(font2);

    gridLayout->addWidget(lineEdit_preson, 0, 1, 1, 1);

    label_sn = new QLabel(widget);
    label_sn->setObjectName(QString::fromUtf8("label_sn"));
    label_sn->setFont(font1);

    gridLayout->addWidget(label_sn, 0, 2, 1, 1);

    lineEdit_sn = new QLineEdit(widget);
    lineEdit_sn->setObjectName(QString::fromUtf8("lineEdit_sn"));
    lineEdit_sn->setMinimumSize(QSize(400, 40));
    lineEdit_sn->setMaximumSize(QSize(400, 40));
    lineEdit_sn->setFont(font2);

    gridLayout->addWidget(lineEdit_sn, 0, 3, 1, 1);

    widget1 = new QWidget(centralwidget);
    widget1->setObjectName(QString::fromUtf8("widget1"));
    widget1->setGeometry(QRect(771, 11, 318, 89));
    gridLayout_cpu = new QGridLayout(widget1);
    gridLayout_cpu->setObjectName(QString::fromUtf8("gridLayout_cpu"));
    gridLayout_cpu->setContentsMargins(0, 0, 0, 0);
    groupBox_cputmp = new QGroupBox(widget1);
    groupBox_cputmp->setObjectName(QString::fromUtf8("groupBox_cputmp"));
    groupBox_cputmp->setFont(font);
    gridLayout_8 = new QGridLayout(groupBox_cputmp);
    gridLayout_8->setObjectName(QString::fromUtf8("gridLayout_8"));
    label_cputmp = new QLabel(groupBox_cputmp);
    label_cputmp->setObjectName(QString::fromUtf8("label_cputmp"));
    label_cputmp->setMinimumSize(QSize(130, 40));
    label_cputmp->setMaximumSize(QSize(130, 40));
    QFont font3;
    font3.setPointSize(30);
    font3.setBold(true);
    font3.setWeight(75);
    label_cputmp->setFont(font3);

    gridLayout_8->addWidget(label_cputmp, 0, 0, 1, 1);


    gridLayout_cpu->addWidget(groupBox_cputmp, 0, 0, 1, 1);

    groupBox_cpuused = new QGroupBox(widget1);
    groupBox_cpuused->setObjectName(QString::fromUtf8("groupBox_cpuused"));
    groupBox_cpuused->setFont(font);
    gridLayout_6 = new QGridLayout(groupBox_cpuused);
    gridLayout_6->setObjectName(QString::fromUtf8("gridLayout_6"));
    label_cpuused = new QLabel(groupBox_cpuused);
    label_cpuused->setObjectName(QString::fromUtf8("label_cpuused"));
    label_cpuused->setMinimumSize(QSize(130, 40));
    label_cpuused->setMaximumSize(QSize(40, 16777215));
    label_cpuused->setFont(font3);

    gridLayout_6->addWidget(label_cpuused, 0, 0, 1, 1);


    gridLayout_cpu->addWidget(groupBox_cpuused, 0, 1, 1, 1);

    widget2 = new QWidget(centralwidget);
    widget2->setObjectName(QString::fromUtf8("widget2"));
    widget2->setGeometry(QRect(40, 110, 1106, 211));
    gridLayout_testitem = new QGridLayout(widget2);
    gridLayout_testitem->setObjectName(QString::fromUtf8("gridLayout_testitem"));
    gridLayout_testitem->setContentsMargins(0, 0, 0, 0);
    groupBox_perf = new QGroupBox(widget2);
    groupBox_perf->setObjectName(QString::fromUtf8("groupBox_perf"));
    QFont font4;
    font4.setPointSize(20);
    font4.setBold(true);
    font4.setUnderline(false);
    font4.setWeight(75);
    font4.setKerning(true);
    groupBox_perf->setFont(font4);
    gridLayout_3 = new QGridLayout(groupBox_perf);
    gridLayout_3->setObjectName(QString::fromUtf8("gridLayout_3"));
    pBtn_cpugpu = new QPushButton(groupBox_perf);
    pBtn_cpugpu->setObjectName(QString::fromUtf8("pBtn_cpugpu"));
    pBtn_cpugpu->setMinimumSize(QSize(200, 50));
    QFont font5;
    font5.setPointSize(24);
    font5.setBold(false);
    font5.setWeight(50);
    pBtn_cpugpu->setFont(font5);
    pBtn_cpugpu->setStyleSheet(QString::fromUtf8(""));

    gridLayout_3->addWidget(pBtn_cpugpu, 1, 0, 1, 1);


    gridLayout_testitem->addWidget(groupBox_perf, 0, 3, 1, 1);

    groupBox_base = new QGroupBox(widget2);
    groupBox_base->setObjectName(QString::fromUtf8("groupBox_base"));
    groupBox_base->setFont(font);
    groupBox_base->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
    gridLayout_5 = new QGridLayout(groupBox_base);
    gridLayout_5->setObjectName(QString::fromUtf8("gridLayout_5"));
    pBtn_OSactive = new QPushButton(groupBox_base);
    pBtn_OSactive->setObjectName(QString::fromUtf8("pBtn_OSactive"));
    pBtn_OSactive->setMinimumSize(QSize(200, 50));
    pBtn_OSactive->setFont(font5);
    pBtn_OSactive->setStyleSheet(QString::fromUtf8(""));

    gridLayout_5->addWidget(pBtn_OSactive, 1, 0, 1, 1);

    pBtn_hardware_check = new QPushButton(groupBox_base);
    pBtn_hardware_check->setObjectName(QString::fromUtf8("pBtn_hardware_check"));
    pBtn_hardware_check->setMinimumSize(QSize(200, 50));
    pBtn_hardware_check->setFont(font5);
    pBtn_hardware_check->setStyleSheet(QString::fromUtf8(""));

    gridLayout_5->addWidget(pBtn_hardware_check, 0, 0, 1, 1);

    pBtn_net = new QPushButton(groupBox_base);
    pBtn_net->setObjectName(QString::fromUtf8("pBtn_net"));
    pBtn_net->setMinimumSize(QSize(200, 50));
    pBtn_net->setFont(font5);
    pBtn_net->setStyleSheet(QString::fromUtf8(""));

    gridLayout_5->addWidget(pBtn_net, 2, 0, 1, 1);


    gridLayout_testitem->addWidget(groupBox_base, 0, 0, 1, 1);

    groupBox_media = new QGroupBox(widget2);
    groupBox_media->setObjectName(QString::fromUtf8("groupBox_media"));
    groupBox_media->setMinimumSize(QSize(200, 0));
    groupBox_media->setFont(font4);
    gridLayout_4 = new QGridLayout(groupBox_media);
    gridLayout_4->setObjectName(QString::fromUtf8("gridLayout_4"));
    pBtn_audio = new QPushButton(groupBox_media);
    pBtn_audio->setObjectName(QString::fromUtf8("pBtn_audio"));
    pBtn_audio->setMinimumSize(QSize(200, 50));
    pBtn_audio->setFont(font5);
    pBtn_audio->setStyleSheet(QString::fromUtf8(""));

    gridLayout_4->addWidget(pBtn_audio, 0, 0, 1, 1);

    pBtn_record = new QPushButton(groupBox_media);
    pBtn_record->setObjectName(QString::fromUtf8("pBtn_record"));
    pBtn_record->setMinimumSize(QSize(200, 50));
    pBtn_record->setFont(font5);
    pBtn_record->setStyleSheet(QString::fromUtf8(""));

    gridLayout_4->addWidget(pBtn_record, 1, 0, 1, 1);


    gridLayout_testitem->addWidget(groupBox_media, 0, 2, 1, 1);

    groupBox_hardware = new QGroupBox(widget2);
    groupBox_hardware->setObjectName(QString::fromUtf8("groupBox_hardware"));
    groupBox_hardware->setFont(font4);
    gridLayout_2 = new QGridLayout(groupBox_hardware);
    gridLayout_2->setObjectName(QString::fromUtf8("gridLayout_2"));
    pBtn_usb = new QPushButton(groupBox_hardware);
    pBtn_usb->setObjectName(QString::fromUtf8("pBtn_usb"));
    pBtn_usb->setMinimumSize(QSize(200, 50));
    pBtn_usb->setFont(font5);
    pBtn_usb->setStyleSheet(QString::fromUtf8(""));

    gridLayout_2->addWidget(pBtn_usb, 0, 0, 1, 1);

    pBtn_camera = new QPushButton(groupBox_hardware);
    pBtn_camera->setObjectName(QString::fromUtf8("pBtn_camera"));
    pBtn_camera->setMinimumSize(QSize(200, 50));
    pBtn_camera->setFont(font5);
    pBtn_camera->setStyleSheet(QString::fromUtf8(""));

    gridLayout_2->addWidget(pBtn_camera, 0, 1, 1, 1);

    pBtn_disk = new QPushButton(groupBox_hardware);
    pBtn_disk->setObjectName(QString::fromUtf8("pBtn_disk"));
    pBtn_disk->setMinimumSize(QSize(200, 50));
    pBtn_disk->setFont(font5);
    pBtn_disk->setStyleSheet(QString::fromUtf8(""));

    gridLayout_2->addWidget(pBtn_disk, 1, 0, 1, 1);

    pBtn_dvd = new QPushButton(groupBox_hardware);
    pBtn_dvd->setObjectName(QString::fromUtf8("pBtn_dvd"));
    pBtn_dvd->setMinimumSize(QSize(200, 50));
    pBtn_dvd->setFont(font5);
    pBtn_dvd->setStyleSheet(QString::fromUtf8(""));

    gridLayout_2->addWidget(pBtn_dvd, 1, 1, 1, 1);


    gridLayout_testitem->addWidget(groupBox_hardware, 0, 1, 1, 1);

    this->setCentralWidget(centralwidget);
    statusbar = new QStatusBar(this);
    statusbar->setObjectName(QString::fromUtf8("statusbar"));
    this->setStatusBar(statusbar);

    retranslateUi();

    QMetaObject::connectSlotsByName(this);
}

void MainWindow::retranslateUi()
{
    groupBox_last->setTitle(QApplication::translate("MainWindow", "\346\234\200\345\220\216\344\270\200\346\255\245", nullptr));
    pBtn_export->setText(QApplication::translate("MainWindow", "\347\273\223\346\236\234\345\257\274\345\207\272", nullptr));
    pBtn_shutdown->setText(QApplication::translate("MainWindow", "\350\277\230\345\216\237\345\271\266\345\205\263\346\234\272", nullptr));
    label_preson->setText(QApplication::translate("MainWindow", "\346\265\213\350\257\225\345\221\230\357\274\232", nullptr));
    lineEdit_preson->setText(QString());
    label_sn->setText(QApplication::translate("MainWindow", "SN\357\274\232", nullptr));
    lineEdit_sn->setText(QString());
    groupBox_cputmp->setTitle(QApplication::translate("MainWindow", "CPU\346\270\251\345\272\246", nullptr));
    label_cputmp->setText(QApplication::translate("MainWindow", "75\342\204\203", nullptr));
    groupBox_cpuused->setTitle(QApplication::translate("MainWindow", "CPU\344\275\277\347\224\250\347\216\207", nullptr));
    label_cpuused->setText(QApplication::translate("MainWindow", "50%", nullptr));
    groupBox_perf->setTitle(QApplication::translate("MainWindow", "\346\200\247\350\203\275\346\265\213\350\257\225", nullptr));
    pBtn_cpugpu->setText(QApplication::translate("MainWindow", "\347\250\263\345\256\232\346\200\247\346\265\213\350\257\225", nullptr));
    groupBox_base->setTitle(QApplication::translate("MainWindow", "\345\237\272\347\241\200\346\265\213\350\257\225\351\241\271", nullptr));
    pBtn_OSactive->setText(QApplication::translate("MainWindow", "\347\263\273\347\273\237\346\277\200\346\264\273\346\265\213\350\257\225", nullptr));
    pBtn_hardware_check->setText(QApplication::translate("MainWindow", "\351\205\215\347\275\256\346\240\270\345\257\271", nullptr));
    pBtn_net->setText(QApplication::translate("MainWindow", "\347\275\221\347\273\234\346\243\200\346\265\213", nullptr));
    groupBox_media->setTitle(QApplication::translate("MainWindow", "\345\244\232\345\252\222\344\275\223\346\265\213\350\257\225", nullptr));
    pBtn_audio->setText(QApplication::translate("MainWindow", "\346\211\254\345\243\260\345\231\250\346\265\213\350\257\225", nullptr));
    pBtn_record->setText(QApplication::translate("MainWindow", "\351\272\246\345\205\213\351\243\216\346\265\213\350\257\225", nullptr));
    groupBox_hardware->setTitle(QApplication::translate("MainWindow", "\347\241\254\344\273\266\346\265\213\350\257\225", nullptr));
    pBtn_usb->setText(QApplication::translate("MainWindow", "USB\346\265\213\350\257\225", nullptr));
    pBtn_camera->setText(QApplication::translate("MainWindow", "\346\221\204\345\203\217\345\244\264\346\265\213\350\257\225", nullptr));
    pBtn_disk->setText(QApplication::translate("MainWindow", "\347\241\254\347\233\230\346\265\213\350\257\225", nullptr));
    pBtn_dvd->setText(QApplication::translate("MainWindow", "DVD\346\265\213\350\257\225", nullptr));
}// retranslateUi

void MainWindow::btnConnect()
{
    connect(pBtn_hardware_check,&QPushButton::clicked,this,&MainWindow::onHardwareCheckClicked);
    connect(pBtn_OSactive,&QPushButton::clicked,this,&MainWindow::onOSActiveClicked);
    connect(pBtn_net,&QPushButton::clicked,this,&MainWindow::onNetCheckClicked);
    connect(pBtn_usb,&QPushButton::clicked,this,&MainWindow::onUSBCheckClicked);
    connect(pBtn_camera,&QPushButton::clicked,this,&MainWindow::onCameraCheckClicked);
    connect(pBtn_disk,&QPushButton::clicked,this,&MainWindow::onDiskCheckClicked);
    connect(pBtn_dvd,&QPushButton::clicked,this,&MainWindow::onDVDCheckClicked);
    connect(pBtn_audio,&QPushButton::clicked,this,&MainWindow::onAudioCheckClicked);
    connect(pBtn_record,&QPushButton::clicked,this,&MainWindow::onRecordCheckClicked);
    connect(pBtn_cpugpu,&QPushButton::clicked,this,&MainWindow::onCPUGPUCheckClicked);
    connect(pBtn_export,&QPushButton::clicked,this,&MainWindow::onExportClicked);
    connect(pBtn_shutdown,&QPushButton::clicked,this,&MainWindow::onShutdownClicked);




}

void MainWindow::setBtnColorByRes(QPushButton *pBtn, bool res)
{
    if(res){
        pBtn->setStyleSheet(greenBtnStyle);
    }else {
        if(pBtn == pBtn_net || pBtn == pBtn_OSactive){
            pBtn->setStyleSheet(greyBtnStyle);
        }else{
        pBtn->setStyleSheet(redBtnStyle);
        }
    }
}



void MainWindow::onHardwareCheckClicked()
{
    //硬件对比逻辑


    //结果截图
    pBtn_hardware_check->setStyleSheet(greenBtnStyle);

}

//查看系统激活状态,日志显示激活状态和激活到期时间
void MainWindow::onOSActiveClicked()
{
    bool isActive = false;
    //功能实现



    //结果截图

    //未激活显示灰色，激活显示绿色
    setBtnColorByRes(pBtn_OSactive,isActive);
}

//查看网络状态
void MainWindow::onNetCheckClicked()
{
    bool isConnect = false;
    //功能实现


    //无网络连接则为灰色,有则为绿色
    setBtnColorByRes(pBtn_net,isConnect);

}

//检查USB可用性
void MainWindow::onUSBCheckClicked()
{
    bool isPass = false;

    //功能实现


    //
    setBtnColorByRes(pBtn_usb,isPass);

}

//检查摄像头
void MainWindow::onCameraCheckClicked()
{
    bool isPass = false;

    //
    setBtnColorByRes(pBtn_camera,isPass);

}

//检查硬盘
void MainWindow::onDiskCheckClicked()
{
    bool isPass = false;

    //
    setBtnColorByRes(pBtn_disk,isPass);
}

//检查dvd
void MainWindow::onDVDCheckClicked()
{
    bool isPass = false;

    //
    setBtnColorByRes(pBtn_dvd,isPass);
}

//检查扬声器播放功能
void MainWindow::onAudioCheckClicked()
{
    bool isPass = false;

    //
    setBtnColorByRes(pBtn_audio,isPass);
}

//检查麦克风录音功能
void MainWindow::onRecordCheckClicked()
{
    bool isPass = false;

    //
    setBtnColorByRes(pBtn_record,isPass);
}

//稳定性测试，cpu和gpu跑满测稳定性
void MainWindow::onCPUGPUCheckClicked()
{
    bool isPass = false;

    //
    setBtnColorByRes(pBtn_cpugpu,isPass);
}

//导出功能
void MainWindow::onExportClicked()
{

}

//还原并关机
void MainWindow::onShutdownClicked()
{

}





